package com.ruoyi.system.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.OrderContrastDetail;
import com.ruoyi.system.service.IOrderContrastDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 返佣对比信息Controller
 *
 * @author hjf
 * @date 2025-06-06
 */
@RestController
@RequestMapping("/hmk/contrastDetail")
public class OrderContrastDetailController extends BaseController {
    @Autowired
    private IOrderContrastDetailService orderContrastDetailService;

    /**
     * 查询返佣对比信息列表
     */
    @PreAuthorize("@ss.hasPermi('hmk:contrastDetail:list')")
    @GetMapping("/list")
    public TableDataInfo list(OrderContrastDetail orderContrastDetail) {
        startPage();
        List<OrderContrastDetail> list = orderContrastDetailService.selectOrderContrastDetailList(orderContrastDetail);
        return getDataTable(list);
    }

    /**
     * 导出返佣对比信息列表
     */
    @PreAuthorize("@ss.hasPermi('hmk:contrastDetail:export')")
    //@Log(title = "返佣对比信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OrderContrastDetail orderContrastDetail) {
        List<OrderContrastDetail> list = orderContrastDetailService.selectOrderContrastDetailList(orderContrastDetail);
        ExcelUtil<OrderContrastDetail> util = new ExcelUtil<OrderContrastDetail>(OrderContrastDetail.class);
        util.exportExcel(response, list, "返佣对比信息数据");
    }

    /**
     * 获取返佣对比信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('hmk:contrastDetail:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(orderContrastDetailService.selectOrderContrastDetailById(id));
    }

    /**
     * 新增返佣对比信息
     */
    @PreAuthorize("@ss.hasPermi('hmk:contrastDetail:add')")
    //@Log(title = "返佣对比信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OrderContrastDetail orderContrastDetail) {
        return toAjax(orderContrastDetailService.insertOrderContrastDetail(orderContrastDetail));
    }

    /**
     * 修改返佣对比信息
     */
    @PreAuthorize("@ss.hasPermi('hmk:contrastDetail:edit')")
    //@Log(title = "返佣对比信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OrderContrastDetail orderContrastDetail) {
        return toAjax(orderContrastDetailService.updateOrderContrastDetail(orderContrastDetail));
    }

    /**
     * 删除返佣对比信息
     */
    @PreAuthorize("@ss.hasPermi('hmk:contrastDetail:remove')")
    //@Log(title = "返佣对比信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(orderContrastDetailService.deleteOrderContrastDetailByIds(ids));
    }
}
